﻿@{
    ViewBag.Title = "Info";
}

<h2>Course Information</h2>
@if (ViewBag.Number == null)
{
    @: The course does not exist!
    return;
}
<b>Number:</b> @ViewBag.Number <br />
<b>Name:</b> @ViewBag.Name <br />
<b>Points:</b> @ViewBag.Points <br />
<b>Faculty:</b> @ViewBag.Faculty <br /><br />

@if (ViewBag.Notes != null && ViewBag.Notes != "")
{
    <b>Notes:</b>
    @ViewBag.Notes <br /><br />
}

<b>Lecturer In Charge:</b> @ViewBag.LecturerInCharge <br /><br />

<b>Term A:</b> @if (ViewBag.TermA != null)
               {
                    @ViewBag.TermA
               }
               else
               {
                   @: There is no exam!
               }
               <br />
<b>Term B:</b> @if (ViewBag.TermB != null)
               {
                    @ViewBag.TermB
               }
               else
               {
                   @: There is no exam!
               }
               <br /><br />


<b>Groups:</b><br />
@if(ViewBag.Groups != null && ViewBag.Groups.Count != 0)
{
<table>
   <thead>
       <td>
          <b>Number</b>
       </td>
       <td>
           <b>Lesson</b>
       </td>
       <td>
           <b>Teacher</b>
       </td>
       <td>
           <b>Day</b>
       </td>
       <td>
           <b>Start Time</b>
       </td>
       <td>
           <b>Duration(In hours)</b>
       </td>
       <td>
           <b>Place</b>
       </td>
   </thead>
  @foreach( eDonkeyClassLibrary.Group group in ViewBag.Groups)
  {
   <tr>
       <td>
        @group.Number
       </td>
       <td>
        @if(group.Role == "Lecture")
        {
               ViewBag.Color = "blue";
        }
        else if(group.Role == "Tutorial")
        {
               ViewBag.Color = "green";
        }
        <font color=@ViewBag.Color>
        @group.Role
        </font>
       </td>
       <td>
        @if(group.Teacher != null)
        {
            @group.Teacher.FirstName
            @:&nbsp
            @group.Teacher.LastName
        }
       </td>
       @if(group.PlaceTimes != null && group.PlaceTimes.Count !=0)
       {
       <td>
         @group.PlaceTimes[0].Day
       </td>
       <td>
         @group.PlaceTimes[0].StartTime
       </td>
       <td>
         @group.PlaceTimes[0].Duration
       </td>
       <td>
        @group.PlaceTimes[0].Place
       </td>
       }
   </tr>
      if(group.PlaceTimes.Count > 1)
      {
          for(int i=1; i<group.PlaceTimes.Count; i++)
          {
          <tr>
              <td></td><td></td><td></td>
              <td>
                 @group.PlaceTimes[i].Day
              </td>
              <td>
                 @group.PlaceTimes[i].StartTime
              </td>
              <td>
                 @group.PlaceTimes[i].Duration
              </td>
              <td>
                @group.PlaceTimes[i].Place
              </td>
          </tr>   
          }
          
      }
   }
</table>
}
else
{
    @: There are no groups!   
}

<br /><br />
<a href=@ViewBag.link>Select</a>
